package com.cgx.config;

import com.cgx.webmagic.MyPageProcessor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component;
import us.codecraft.webmagic.Spider;

import javax.annotation.PostConstruct;

/**
 * @author chenguanxin
 * @date 2020-07-17 22:43
 */
@Component
public class WebMagicConfig {

    @Autowired
    MyPageProcessor myPageProcessor;

    @PostConstruct
    public void start() {
        Spider.create(myPageProcessor).addUrl("http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2019/index.html").thread(4).start();
    }
}
